'use strict'

//定制主题
import {darkTheme, lightTheme} from 'naive-ui'
import {useGlobalConf} from '@/utils/useGlobalConf'
import {rgba, toRgbaString} from "seemly"
import {whiteTheme, blackTheme} from '@/assets/theme/index'
import {merge} from 'lodash'
const {globalConf} = useGlobalConf()

const themeOverride = reactive({})
watchEffect(() => {
    //init
    merge(themeOverride, globalConf.appTheme === 'white' ? whiteTheme : blackTheme)
    merge(themeOverride.common, {
        primaryColor: globalConf.appPrimaryColor,
        primaryColorHover: globalConf.appPrimaryHoverColor,
        primaryColorPressed: globalConf.appPrimaryPressedColor,
        primaryColorSuppl: globalConf.appPrimarySupplColor,
        minorPrimaryColor: globalConf.appMinorPrimaryColor,
    })
    //十六进制转rgba
    let intoRgba = rgba(globalConf.appPrimaryColor)
    intoRgba[3] = .15
    themeOverride.common.primaryBackgroundColor = toRgbaString(intoRgba)
})

export const theme = computed(() => globalConf.appTheme === 'white' ? lightTheme : darkTheme)
export default themeOverride